/*
 * @Author: guoyangf
 * @Date: 2020-05-28 16:34:13
 * @LastEditTime: 2020-09-21 17:17:40
 * @Description: 模板数据处理器
 */



function tabTplHandle(metaTpl, codeList) {
    let tabList = [];

    return tabList;
}

function tableCardTplHandle(templates) {
    for (let key in templates) {
        let tpl = templates[key];
        tpl.sort((a, b) => a.position - b.position);
        tpl = tpl.filter(item => item.visible);
    }
    return templates
}

function tableTplHandle() {

}



function searchTplHandle(config, tabCode, area, specialDisplayCondition, multiLang) {

    let specialDisplayConditionObj = {};
    specialDisplayCondition.forEach((item) => {
        specialDisplayConditionObj[item.queryField] = item;
    })
    let searchTpl =
    {
        tabCode: tabCode,
        isShow: false,
        searchTplArea: area,
        specialDisplayCondition: specialDisplayConditionObj,
        customField: [
            {
                label: multiLang['job-common-search-gdtj'], /* 更多条件 */
                itemtype: 'multi-lv',
                col: 2,
                attrcode: '',
                children: [
                    {
                        label: multiLang['job-common-search-sm'], /* 扫码 */
                        attrcode: 'barcode',
                        itemtype: 'barcode',
                        placeholder: multiLang['job-common-search-tmsm'], /*条码扫描*/
                    }
                ]

            }
        ]
    }

    let autoOpen = {
        label: multiLang['job-common-search-zddk'], /* 自动打开 */
        attrcode: 'autoopen',
        itemtype: 'checkbox'
    }

    let customeArr = searchTpl.customField[0].children;
    switch (this.props.sscAppType) {
        case 'sscfile': //我的打印
            if (tabCode == 'done') { //已完成页签不显更多条件
                searchTpl.customField = [];
            } else {
                customeArr.push({

                    label: multiLang['job-file-search-xshd'],
                    attrcode: 'insertbefore',
                    itemtype: 'checkbox'

                })
            }


            break;
        case 'sscaudit': //我的稽核
            customeArr.push(autoOpen);
            break;
        case 'sscapprove': //我的审核
        case 'sscsettle': //我的结算
            customeArr.push(
                {
                    label: multiLang['job-common-search-mhcx'],
                    attrcode: 'fuzzySearch',
                    itemtype: 'fuzzySearch',
                    placeholder: multiLang['job-common-search-mhcx'] /* 模糊查询 */
                }
            )
            customeArr.push(autoOpen);
            break;
    }

    return searchTpl;

}

export { searchTplHandle, tableCardTplHandle }



